import { ref, toRefs } from "vue"
//导入map
import { useMapStore } from "../../stores/mapStore"
const { mapState } = toRefs(useMapStore())
export const useToggleLayer = () => {
  //显示切换地图弹窗
  const showToggle = ref(false)
  //切换矢量图层和栅格图层
  function toggleMap(type) {
    const layerArray = mapState.value.map.getLayers().getArray()
    if (type == "raster") {
      layerArray[0].setVisible(true)
      layerArray[1].setVisible(false)
    } else {
      layerArray[0].setVisible(false)
      layerArray[1].setVisible(true)
    }
    showToggle.value = false
    mapState.value.showCube = false
  }
  //显示mapbox
  function showMapBox() {
    mapState.value.showCube = true
    console.log(mapState.value)
    showToggle.value = false
  }
  return { showToggle, toggleMap, showMapBox }
}
